import 'package:flutter/material.dart';
import 'package:flutter_color_plugin/flutter_color_plugin.dart';
import 'package:yw_bapp/model/news_list_model.dart';
import 'package:yw_bapp/utils/timeHandle.dart';
import 'package:yw_bapp/widgets/m_btn.dart';
import 'package:yw_bapp/widgets/text_image_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:intl/intl.dart';

var successColor = ColorUtil.color("#FF0091FF");
var failColor = ColorUtil.color("#FFFF7100");
var pendingColor = ColorUtil.color("#FF00B178");

class WithdrawalItem extends StatelessWidget {
  final int type;
  final ApplyList item;

  const WithdrawalItem({Key key, this.type = 1, this.item}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var timeSamp = DateUtils.instance
        .GLDataExchange(item.createdAt, format: 'yyy/MM/dd  HH:mm:ss')
        .toString();
    return type == 1
        ? Card(
            //z轴的高度，设置card的阴影
            elevation: 5,
            //设置shape，这里设置成了R角
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(5.0)),
            ),
            //对Widget截取的行为，比如这里 Clip.antiAlias 指抗锯齿
            clipBehavior: Clip.antiAlias,
            semanticContainer: false,
            child: getChild(context, timeSamp),
          )
        : nomalItem(context, timeSamp);
  }

// 卡片的风格样式
  Widget getChild(BuildContext context, String timeSamp) {
    return Container(
      color: Colors.white,
      padding: EdgeInsets.fromLTRB(15, 26, 15, 26),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              LimitedBox(
                maxWidth: 208,
                child: Text(
                  '${item.applicantName} 兑现到  ${item.bankName} (尾号${item.bankAccount})',
                  style: TextStyle(fontSize: 13, color: Colors.black),
                  softWrap: true,
                ),
              ),
              TextWithImage(
                title: '+${item.centScorePrice / 100}',
                imageUrl: 'images/bean.png',
                imgHeight: 12,
                imgWdth: 12,
                textStyle: TextStyle(
                    color: ColorUtil.color("#FF333333"), fontSize: 18),
              ),
            ],
          ),
          Container(
            margin: EdgeInsets.only(top:9),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                // 日期
                Text(
                  '$timeSamp',
                  // '${DateUtils.instance.getFormartData(timeSamp:new DateTime.now().millisecondsSinceEpoch+0 * 24 * 60 * 60 * 1000,format:"yyy/MM/dd  HH:mm:ss")}',
                  style: TextStyle(
                    fontSize: 13,
                    color: Colors.black,
                  ),
                ),
                MBtn(
                  borderColor: (item.status == '审核成功'
                      ? successColor
                      : item.status == "审核失败" ? failColor : pendingColor),
                  function: null,
                  title: item.status,
                  btnWidth: 56,
                  btnHeight: 18,
                  borderRadius: 2,
                  textStyle: TextStyle(fontSize: 11),
                )
              ],
            ),
          )
        ],
      ),
    );
  }

// 普通的一项
  Widget nomalItem(BuildContext context, timeSamp) {
    return Container(
      decoration: BoxDecoration(
          border:
              Border(bottom: BorderSide(color: Color.fromRGBO(0, 0, 0, 0.1)))),
      child: getChild(context, timeSamp),
    );
  }
}
